import {
  Column,
  Entity,
  JoinColumn,
  JoinTable,
  ManyToMany,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { Department } from '../../department/entities/department.entity';
import { Major } from '../../major/entities/major.entity';
import { LessonsSort } from '../../lessons-sort/entities/lessons-sort.entity';
import { Student } from '../../student/entities/student.entity';

/**
 * 班级信息
 */
@Entity()
export class ClassInfo {
  @PrimaryGeneratedColumn({ type: 'int', comment: '班级ID' })
  id: number;

  @Column({ comment: '班级编码', unique: true })
  class_code: string;

  @Column({ comment: '班级姓名', unique: true })
  name: string;

  @Column({ type: 'int', comment: '班级人数', nullable: true })
  class_count: number;

  @OneToMany(() => Student, (student) => student.classInfo, {
    onDelete: 'SET NULL',
  })
  student: Student[];

  // 学院
  // @ManyToOne(() => Department, (department) => department.student, {
  //   nullable: false,
  // })
  // @JoinColumn({
  //   name: 'department_id',
  //   referencedColumnName: 'id',
  // })
  // department: Department;

  // 专业
  // @ManyToOne(() => Major, (major) => major.student, { nullable: false })
  // @JoinColumn({
  //   name: 'major_id',
  //   referencedColumnName: 'id',
  // })
  // major: Major;

  // @ManyToMany(() => LessonsSort)
  // lessonsSorts: LessonsSort[];
}
